package com.example.demo.controller;

import com.example.demo.bean.ConfigBean;
import com.example.demo.bean.ConfigUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@EnableConfigurationProperties({ConfigBean.class, ConfigUser.class})
public class HelloController {
    @Autowired
    private ConfigBean configBean;

    @Autowired
    private ConfigUser configUser;

    @GetMapping("/hello")
    public String hello() {
        return configBean.toString();
    }

    @GetMapping("/configUser")
    public String user() {
        return configUser.getName()+" : "+ configUser.getAge();
    }
}
